
import { getShopOPtions } from "@/apis/shop"
import { getBillStatis } from "@/apis/bill"
import { PayOptions, TypeOptions } from "@/views/bill/constant"
import textTitle from "@/components/textTitle"
import store from "@/store"
export default async (that)=>{
	let {shopName,shopId} = that.$attrs
	let {data:ShopOptions} = await getShopOPtions()
	store.commit("option/setShopOPtion",ShopOptions)
	return {
		columns:[
			{
				key:"billNo",
				label:"账单编号",
				width:300,
			},
			{
				key:"shopName",
				label:"店铺名",
				// width:400
				width:200,
				props:{
					"show-overflow-tooltip":true
				}
			},
			{
				key:"status",
				label:"状态",
				// width:100,
				slot:"status"
			},
			{
				key:"total",
				label:"总金额",
				headerSlot:"orderMoney"
			},
			{
				key:"platform",
				label:"平台类型",
				slot:"platform"
			},
			{
				key:"name",
				label:"所属销售"
				// width:200,
			},
			{
				key:"activeDate",
				label:"活动日期"
			},
			// {
			// 	key:"createTime",
			// 	label:"创建时间",
			// 	width:200,
			// },
			// {
			// 	key:"updateTime",
			// 	label:"修改时间",
			// 	width:200,
			// },
			{
				key:"operation",
				label:"操作",
				slot:"operation",
				width:150,
				// props:{
				// 	fixed:"right"
				// },
				removeBtn:{
					show:true,
					permission:"bill:delete"
				},
				editBtn:{
					show:false,
				},
			}
		],
		reqOptions:{
			list:{
				method:"get",
				url:"/bill",
				callback(that){
					let form = that.search.form || {}
					getBillStatis(form).then(res=>{
						that.$emit("updateCount",res.data)
					})
					that.$parent.initDate(that.tableData)

				}   
			},
			insert:{
				method:"post",
				url:"/bill"
			},
			update:{
				method:"put",
				url:"/bill"
			},
			remove:{
				method:"delete",
				url:"/bill/${id}"
			}
		},
		search:{
			form:{
				shopName,
			},
			options:[
				
				// {
				// 	key:"shopId",
				// 	type:"el-select",
				// 	label:"店铺",
				// 	required:false,
				// 	options:ShopOptions,
				// 	props:{
				// 		clearable:true,
				// 		filterable:true
				// 	}
				// },
				{
					key:"billNo",
					type:"el-input",
					label:"账单编号",
					required:false,
					props:{
						clearable:true
					}
    
				},
				
				{
					key:"activeDate",
					label:"活动日期",
					type:"el-date-picker",
					props:{
						type:"date",
						format:"yyyy-MM-dd",
						"value-format":"yyyy-MM-dd"
					},
					required:false
				},
				
				{
					key:"platform",
					type:"el-select",
					label:"平台类型",
					required:false,
					options:TypeOptions,
					props:{
						clearable:true
					}
				},
				
				{
					key:"test",
					type:"el-button",
					label:"查询",
					removeLabel:true,
					width:false,
					props:{
						type:"primary",
						// size:"medium"
					},
					listeners:{
						click(...e){
							that.searchFun && that.searchFun instanceof Function && that.searchFun(...e)
							that.$emit("search")
							console.log("click")
							that.getList()
						}
					}
				},
				{
					key:"blank",
					type:"div",
					label:"  ",
					required:false,
					options:ShopOptions,
					props:{
						clearable:true,
						filterable:true
					}
				},
				{
					key:"status",
					type:"el-select",
					label:"支付状态",
					required:false,
					options:PayOptions,
					props:{
						clearable:true
					}
				},
				{
					key:"startTime",
					label:"开始时间",
					type:"el-date-picker",
					// width:"140px",
					props:{
						type:"date",
						format:"yyyy-MM-dd",
						"value-format":"yyyy-MM-dd",
						placeholder:"开始时间"
					},
					// required:true
				},
				{
					key:"endTime",
					label:"结束时间",
					type:"el-date-picker",
					// width:"140px",
					props:{
						type:"date",
						format:"yyyy-MM-dd",
						"value-format":"yyyy-MM-dd",
						placeholder:"结束时间"

					},
					// required:true
				},
				
			],
			direction:"h",
			labelPosition:"right"
		},
		operation:{
			form:{},
			direction:"h",
			options:[
				{
					key:"text",
					type:textTitle,
					removeLabel:true,
					label:"",
					width:false,
					props:{
						text:"账单信息"
					}
				},
				{
					key:"btn1",
					type:"el-button",
					label:"添加",
					width:false,
					removeLabel:true,
					props:{
						type:"primary",
						size:"mini",
						// icon:"el-icon-plus"
					},
					listeners:{
						click:(...e)=>{
							// debugger
							that.$router.push({
								path:"/bill/edit",
								query:{
									type:"add",
									shopId:shopId
								}
							})
						}
					}
				},
				{
					key:"batchChange",
					type:"el-button",
					label:"批量修改订单状态",
					slot:"batchChange",
					width:false,
					removeLabel:true,
					props:{
						type:"danger",
						size:"mini",
					},
				},
				{
					key:"btn2",
					type:"el-button",
					label:"返回",
					width:false,
					removeLabel:true,
					listeners:{
						click(){
							setTimeout(()=>{
								that.$router.back()
							})
						}
					},
					props:{
						size:"mini"
					}
				}
			]
		},
		updateField:async (form={})=>{
			return {
				form,
				direction:"h",
				options:[
				]
			}
		},
		config:{
			dialog:{
				top:"3vh"
			},
			table:{
				// autoHeight:false
				checkbox:true
			},
			search:{
				show:true
			}
		}
        
	}
}